package com.outdoor.server.mapper;

import com.github.pagehelper.Page;
import com.outdoor.pojo.dto.AdminPageQueryDTO;
import com.outdoor.pojo.entity.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AdminMapper {

    /**
     * 根据用户名获取管理员信息
     * @param username
     * @return
     */
    @Select("SELECT * FROM admin WHERE username = #{username}")
    Admin selectByUsername(String username);

    /**
     * 新增管理员信息
     * @param admin
     */
    @Insert("INSERT INTO admin(name,username, password,phone, type, status,region_ids, created_time) " +
            "VALUES" +
            "(#{name}, #{username}, #{password},#{phone}, #{type}, #{status}, #{regionIds}, #{createdTime}) ")
    void insert(Admin admin);

    /**
     * 分页查询管理员信息
     * @param adminPageQueryDTO
     * @return
     */
    Page<Admin> pageQuery(AdminPageQueryDTO adminPageQueryDTO);

    /**
     * 根据id获取管理员信息
     * @param id
     * @return
     */
    @Select("SELECT * FROM admin WHERE id = #{id}")
    Admin selectById(Long id);

    /**
     * 更新管理员信息
     * @param admin
     */
    void update(Admin admin);
}
